<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,  user-scalable=no">
    <title>SF-36健康问卷</title>
    <style>

        #table_total td, #table_total_edit td {
            width: 50%;
            text-align: left;
        }

        #table-data dl, #table-data dt, #table-data dd {
            width: 100% !important;
            text-align: left;
        }

        #table-data dd {
            /*margin-left: 1vw;*/
        }

        #table-data dd {
            margin-top: 1vw;
        }

        #table-data dt {
            margin-top: 2vw;
        }

        #sf-36-questions ul {
            width: 100% !important;
        }

        #sf-36-questions ul li {
            list-style-type: none !important;
            display: inline-block !important;
            text-align: left !important;
        }

        #sf-36-questions ul li:nth-child(n + 2) {
            margin-left: 3vw;
        }

        #table_total input {
            border: none;
        }

        #table_total td {
            /*text-align: center;*/
        }

        #gauge_form .dashed-border {
            border-bottom: 1px dashed #d0d0d0;
        }
    </style>
</head>

<body>
<form id="gauge_form">
    <div style="padding-left: 15px;">

        <div class="no-print" style="border-bottom: 1px solid #d0d0d0;">
            <label style="font-size: 16px;font-weight: bold;">评定内容</label>
        </div>

        <div class="hide" style="margin-top: 20px;">
            <table border="0" cellspacing="0" cellpadding="0" style="">
                <tr>
                    <td align="left" style="width: 8vw;vertical-align: middle;"><label style="font-size: 13px">陪同者</label></td>
                    <td align="left" style="vertical-align: middle;"><input id="span_companion_edit" name="text_companion" type="text" class="question-item form-control" style="width: 12vw;"/>
                    </td>
                </tr>
            </table>
        </div>

        <div class="no-print">
            <div id="table-data">
            </div>
        </div>

        <div id="div_edit" class="" style="margin-top: 20px;border-bottom: 1px solid #d0d0d0;">
            <label style="font-size: 16px;font-weight: bold;">评定结果</label>
        </div>

        <div class="">
            <table id="table_total" class="table table-bordered"
                   style="margin-top: 20px;border:1px solid #e7e7e7;" border="1" cellspacing="0" cellpadding="0">
                <tr>
                    <td>生理机能（PF：Physical Functioning）</td>
                    <td><span class="pf" ></span></td>
                </tr>
                <tr>
                    <td>生理职能（RP：Role-Physical）</td>
                    <td><span class="rp" ></span></td>
                </tr>
                <tr>
                    <td>躯体疼痛（BP：Bodily Pain）</td>
                    <td><span class="bp" ></span></td>
                </tr>
                <tr>
                    <td>一般健康状况（GH：General Health）</td>
                    <td><span class="gh" ></span></td>
                </tr>
                <tr>
                    <td>精力（VT：Vitality）</td>
                    <td><span class="vt" ></span></td>
                </tr>
                <tr>
                    <td>社会功能（SF：Social Functioning）</td>
                    <td><span class="sf" ></span></td>
                </tr>
                <tr>
                    <td>情感职能（RE：Role-Emotional）</td>
                    <td><span class="re" ></span></td>
                </tr>
                <tr>
                    <td>精神健康（MH：Mental Health）</td>
                    <td><span class="mh" ></span></td>
                </tr>
            </table>
        </div>

        <div class="edit-page hide" style="margin-top: 20px">
            <div class="col-sm-8 col-sm-offset-4">
                <button class="btn btn-white col-sm-3" type="reset" onclick="myReset()">重置</button>
                <button class="btn btn-primary col-sm-3 col-sm-offset-1" onclick="submitGaugeResult()" type="button">提交
                </button>
            </div>
        </div>

        <div style="margin-top: 5vw;" class="hide">
            <div style="border-bottom: 1px dashed #c2c2c2;"><h3 style="color: red;text-align: center;">本次您的测试结果总分为： 96 (均分： 2.6666666666667 )</h3>
                <p>本次测试开始时间：2016-10-17 08:42:45</p>
                <p>结束时间：2016-10-17 08:43:34</p>
                <p>结束时间：2016-10-17 08:43:34</p>
                <p>测试结果：生理机能（PF）：测量健康状况是否妨碍了正常的生理活动。生理职能（RP）：测量由于生理健康问题所造成的职能限制。躯体疼痛（BP）：测量疼痛程度以及疼痛对日常活动的影响。一般健康状况（GH）：测量个体对自身健康状况及其发展趋势的评价。精力（VT）：测量个体对自身精力和疲劳程度的主观感受。社会功能（SF）：测量生理和心理问题对社会活动的数量和质量所造成的影响，用于评价健康对社会活动的效应。情感职能（RE）：测量由于情感问题所造成的职能限制。精神健康（MH）：测量四类精神健康项目，包括激励、压抑、行为或情感失控、心理主观感受。健康变化（HT），用于评价过去一年内健康状况的总体变化情况。</p>
            </div>
            <div style="margin-top: 2vw;">
                <p>生理机能(PF): 19 (均分： 1.9 ) 总30分。PF得分越高，健康状况越好。</p>
                <p>生理职能(RP): 7 (均分： 1.75 ) 总8分。 RP得分越高，健康状况越好。</p>
                <p>躯体疼痛(BP): 5 (均分： 2.5 ) 总10分。 BP得分越高，健康状况越好。</p>
                <p>一般健康状况(GH): 18 (均分： 3.6 ) 总25分。 GH得分越高，健康状况越好。</p>
                <p>精力(VT): 10 (均分： 2.5 ) 总20分。得分越高，健康状况越好。</p>
                <p>社会功能(SF): 9 (均分： 4.5 ) 总10分。 SF得分越高，健康状况越好。</p>
                <p>情感职能(RE): 6 (均分： 2 ) 总6分。 RE得分越高，健康状况越好。</p>
                <p>精神健康(MH): 19 (均分： 3.8 ) 总分25分。MH得分越高，健康状况越好。</p>
                <p>健康变化(HT): 3 (均分： 3 ) 总5分。 HT得分越高，健康状况变得越差。</p>
            </div>
        </div>

    </div>
</form>
</body>

<script>
    var editPage = $(".edit-page");
    var viewPage = $(".view-page");

    var totalRatio = 0;
    var totalScore = 0;

    // 选项数据json
    var pageData = {
        "data": [
            {
                "groupId": "1",
                "groupName": "总的来说，您认为自己的健康状况是？",
                "item": [
                    {
                        "itemId": "a",
                        "desc": "",
                        "option": [
                            {
                                "id": "1",
                                "desc": "极好",
                                "score": 5
                            },
                            {
                                "id": "2",
                                "desc": "很好",
                                "score": 4.4
                            },
                            {
                                "id": "3",
                                "desc": "好",
                                "score": 3.4
                            },
                            {
                                "id": "4",
                                "desc": "一般",
                                "score": 2
                            },
                            {
                                "id": "5",
                                "desc": "差",
                                "score": 1
                            }
                        ]
                    }
                ]
            },
            {
                "groupId": "2",
                "groupName": "与一年前相比，您认为您目前总的健康状况如何？",
                "item": [
                    {
                        "itemId": "a",
                        "desc": "",
                        "option": [
                            {
                                "id": "1",
                                "desc": "比一年前好多了",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "比一年前好一些",
                                "score": 2
                            },
                            {
                                "id": "3",
                                "desc": "和一年前差不多",
                                "score": 3
                            },
                            {
                                "id": "4",
                                "desc": "比一年前差一些",
                                "score": 4
                            },
                            {
                                "id": "5",
                                "desc": "比一年前差多了",
                                "score": 5
                            }
                        ]
                    }
                ]
            },
            {
                "groupId": "3",
                "groupName": "下列各项是您日常生活中可能进行的活动，以您目前的健康状况，您在进行这些活动时，有没有受到限制？如果有的话，程度如何？",
                "item": [
                    {
                        "itemId": "a",
                        "desc": "剧烈活动，例如跑步，搬重物或参加距离的体育活动",
                        "option": [
                            {
                                "id": "1",
                                "desc": "有很大限制",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "有一点限制",
                                "score": 2
                            },
                            {
                                "id": "3",
                                "desc": "没有任何限制",
                                "score": 3
                            }
                        ]
                    },
                    {
                        "itemId": "b",
                        "desc": "中等强度的活动，如搬桌子，使用吸尘器清洁地面，打太极拳或保龄球",
                        "option": [
                            {
                                "id": "1",
                                "desc": "有很大限制",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "有一点限制",
                                "score": 2
                            },
                            {
                                "id": "3",
                                "desc": "没有任何限制",
                                "score": 3
                            }
                        ]
                    },
                    {
                        "itemId": "c",
                        "desc": "提起或携带蔬菜、食品或杂物",
                        "option": [
                            {
                                "id": "1",
                                "desc": "有很大限制",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "有一点限制",
                                "score": 2
                            },
                            {
                                "id": "3",
                                "desc": "没有任何限制",
                                "score": 3
                            }
                        ]
                    },
                    {
                        "itemId": "d",
                        "desc": "上几层楼",
                        "option": [
                            {
                                "id": "1",
                                "desc": "有很大限制",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "有一点限制",
                                "score": 2
                            },
                            {
                                "id": "3",
                                "desc": "没有任何限制",
                                "score": 3
                            }
                        ]
                    },
                    {
                        "itemId": "e",
                        "desc": "上一层楼",
                        "option": [
                            {
                                "id": "1",
                                "desc": "有很大限制",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "有一点限制",
                                "score": 2
                            },
                            {
                                "id": "3",
                                "desc": "没有任何限制",
                                "score": 3
                            }
                        ]
                    },
                    {
                        "itemId": "f",
                        "desc": "弯腰、跪下或俯身",
                        "option": [
                            {
                                "id": "1",
                                "desc": "有很大限制",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "有一点限制",
                                "score": 2
                            },
                            {
                                "id": "3",
                                "desc": "没有任何限制",
                                "score": 3
                            }
                        ]
                    },
                    {
                        "itemId": "g",
                        "desc": "步行十条街以上（一公里）",
                        "option": [
                            {
                                "id": "1",
                                "desc": "有很大限制",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "有一点限制",
                                "score": 2
                            },
                            {
                                "id": "3",
                                "desc": "没有任何限制",
                                "score": 3
                            }
                        ]
                    },
                    {
                        "itemId": "h",
                        "desc": "步行几条街（几百米）",
                        "option": [
                            {
                                "id": "1",
                                "desc": "有很大限制",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "有一点限制",
                                "score": 2
                            },
                            {
                                "id": "3",
                                "desc": "没有任何限制",
                                "score": 3
                            }
                        ]
                    },
                    {
                        "itemId": "i",
                        "desc": "步行一条街（一百米）",
                        "option": [
                            {
                                "id": "1",
                                "desc": "有很大限制",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "有一点限制",
                                "score": 2
                            },
                            {
                                "id": "3",
                                "desc": "没有任何限制",
                                "score": 3
                            }
                        ]
                    },
                    {
                        "itemId": "j",
                        "desc": "自己洗澡或穿衣服",
                        "option": [
                            {
                                "id": "1",
                                "desc": "有很大限制",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "有一点限制",
                                "score": 2
                            },
                            {
                                "id": "3",
                                "desc": "没有任何限制",
                                "score": 3
                            }
                        ]
                    }
                ]
            },
            {
                "groupId": "4",
                "groupName": "在过去4个星期里，您在工作或其他日常活动中，会不会因为身体健康的原因而遇到下列问题？",
                "item": [
                    {
                        "itemId": "a",
                        "desc": "减少了工作或其他活动时间",
                        "option": [
                            {
                                "id": "1",
                                "desc": "会",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "不会",
                                "score": 2
                            }
                        ]
                    },
                    {
                        "itemId": "b",
                        "desc": "实际做完的比想要做的少",
                        "option": [
                            {
                                "id": "1",
                                "desc": "会",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "不会",
                                "score": 2
                            }
                        ]
                    },
                    {
                        "itemId": "c",
                        "desc": "工作或其他活动的种类受到限制",
                        "option": [
                            {
                                "id": "1",
                                "desc": "会",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "不会",
                                "score": 2
                            }
                        ]
                    },
                    {
                        "itemId": "d",
                        "desc": "进行工作或其他活动时有困难（比如觉得更加吃力）",
                        "option": [
                            {
                                "id": "1",
                                "desc": "会",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "不会",
                                "score": 2
                            }
                        ]
                    }
                ]
            },
            {
                "groupId": "5",
                "groupName": "在过去4个星期里，您在工作或其他日常活动中，会不会因为情绪方面的原因（比如感到沮丧或焦虑）而遇到下列问题？",
                "item": [
                    {
                        "itemId": "a",
                        "desc": "减少了工作或其他活动时间",
                        "option": [
                            {
                                "id": "1",
                                "desc": "会",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "不会",
                                "score": 2
                            }
                        ]
                    },
                    {
                        "itemId": "b",
                        "desc": "实际做完的比想要做的少",
                        "option": [
                            {
                                "id": "1",
                                "desc": "会",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "不会",
                                "score": 2
                            }
                        ]
                    },
                    {
                        "itemId": "c",
                        "desc": "工作或其他活动时不如往常细心了",
                        "option": [
                            {
                                "id": "1",
                                "desc": "会",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "不会",
                                "score": 2
                            }
                        ]
                    }
                ]
            },
            {
                "groupId": "6",
                "groupName": "在过去4个星期里，您的身体健康或情绪在多大程度上妨害了您与家人、朋友、邻居或社团的日常交往活动？",
                "item": [
                    {
                        "itemId": "a",
                        "desc": "",
                        "option": [
                            {
                                "id": "1",
                                "desc": "毫无妨碍",
                                "score": 5
                            },
                            {
                                "id": "2",
                                "desc": "很少妨碍",
                                "score": 4
                            },
                            {
                                "id": "3",
                                "desc": "有一些妨碍",
                                "score": 3
                            },
                            {
                                "id": "4",
                                "desc": "有较大妨碍",
                                "score": 1
                            },
                            {
                                "id": "5",
                                "desc": "有很大妨碍",
                                "score": 1
                            }
                        ]
                    }
                ]
            },
            {
                "groupId": "7",
                "groupName": "在过去4个星期里，您的身体有没有疼痛？如果有的话，疼痛到什么程度？",
                "item": [
                    {
                        "itemId": "a",
                        "desc": "",
                        "option": [
                            {
                                "id": "1",
                                "desc": "完全没有",
                                "score": 6
                            },
                            {
                                "id": "2",
                                "desc": "很轻微",
                                "score": 5.4
                            },
                            {
                                "id": "3",
                                "desc": "轻微",
                                "score": 4.2
                            },
                            {
                                "id": "4",
                                "desc": "有一些",
                                "score": 3.1
                            },
                            {
                                "id": "5",
                                "desc": "剧烈",
                                "score": 2.2
                            },
                            {
                                "id": "6",
                                "desc": "非常剧烈",
                                "score": 1
                            }
                        ]
                    }
                ]
            },
            {
                "groupId": "8",
                "groupName": "在过去4个星期里，您身体上的疼痛对您的日常工作（包括上班和家务劳动）有多大影响？",
                "item": [
                    {
                        "itemId": "a",
                        "desc": "",
                        "option": [
                            {
                                "id": "1",
                                "desc": "毫无影响",
                                "score": 6
                            },
                            {
                                "id": "2",
                                "desc": "有很少影响",
                                "score": 4.75
                            },
                            {
                                "id": "3",
                                "desc": "有一些影响",
                                "score": 3.5
                            },
                            {
                                "id": "4",
                                "desc": "有较大影响",
                                "score": 2.25
                            },
                            {
                                "id": "5",
                                "desc": "有很大影响",
                                "score": 1
                            }
                        ]
                    }
                ]
            },
            {
                "groupId": "9",
                "groupName": "下列问题是有关您在过去4个星期里觉得怎样和您其他的情况。针对每一个问题，请选择一个最接近您的感受的答案。",
                "item": [
                    {
                        "itemId": "a",
                        "desc": "在过去4个星期里有多少时间您觉得生活充实？",
                        "option": [
                            {
                                "id": "1",
                                "desc": "常常如此",
                                "score": 6
                            },
                            {
                                "id": "2",
                                "desc": "大部分时间",
                                "score": 5
                            },
                            {
                                "id": "3",
                                "desc": "相当多时间",
                                "score": 4
                            },
                            {
                                "id": "4",
                                "desc": "有时",
                                "score": 3
                            },
                            {
                                "id": "5",
                                "desc": "偶尔",
                                "score": 2
                            },
                            {
                                "id": "6",
                                "desc": "从来没有",
                                "score": 1
                            }
                        ]
                    },
                    {
                        "itemId": "b",
                        "desc": "在过去4个星期里有多少时间，您觉得精神非常紧张",
                        "option": [
                            {
                                "id": "1",
                                "desc": "常常如此",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "大部分时间",
                                "score": 2
                            },
                            {
                                "id": "3",
                                "desc": "相当多时间",
                                "score": 3
                            },
                            {
                                "id": "4",
                                "desc": "有时",
                                "score": 4
                            },
                            {
                                "id": "5",
                                "desc": "偶尔",
                                "score": 5
                            },
                            {
                                "id": "6",
                                "desc": "从来没有",
                                "score": 6
                            }
                        ]
                    },
                    {
                        "itemId": "c",
                        "desc": "在过去4个星期里有多少时间，您觉得情绪低落，以至于没有任何事能使您高兴起来？",
                        "option": [
                            {
                                "id": "1",
                                "desc": "常常如此",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "大部分时间",
                                "score": 2
                            },
                            {
                                "id": "3",
                                "desc": "相当多时间",
                                "score": 3
                            },
                            {
                                "id": "4",
                                "desc": "有时",
                                "score": 4
                            },
                            {
                                "id": "5",
                                "desc": "偶尔",
                                "score": 5
                            },
                            {
                                "id": "6",
                                "desc": "从来没有",
                                "score": 6
                            }
                        ]
                    },
                    {
                        "itemId": "d",
                        "desc": "在过去4个星期里有多少时间，您感到心平气和？",
                        "option": [
                            {
                                "id": "1",
                                "desc": "常常如此",
                                "score": 6
                            },
                            {
                                "id": "2",
                                "desc": "大部分时间",
                                "score": 5
                            },
                            {
                                "id": "3",
                                "desc": "相当多时间",
                                "score": 4
                            },
                            {
                                "id": "4",
                                "desc": "有时",
                                "score": 3
                            },
                            {
                                "id": "5",
                                "desc": "偶尔",
                                "score": 2
                            },
                            {
                                "id": "6",
                                "desc": "从来没有",
                                "score": 1
                            }
                        ]
                    },
                    {
                        "itemId": "e",
                        "desc": "在过去4个星期里有多少时间，您感到精力充足？",
                        "option": [
                            {
                                "id": "1",
                                "desc": "常常如此",
                                "score": 6
                            },
                            {
                                "id": "2",
                                "desc": "大部分时间",
                                "score": 5
                            },
                            {
                                "id": "3",
                                "desc": "相当多时间",
                                "score": 4
                            },
                            {
                                "id": "4",
                                "desc": "有时",
                                "score": 3
                            },
                            {
                                "id": "5",
                                "desc": "偶尔",
                                "score": 2
                            },
                            {
                                "id": "6",
                                "desc": "从来没有",
                                "score": 1
                            }
                        ]
                    },
                    {
                        "itemId": "f",
                        "desc": "在过去4个星期里有多少时间，您觉得精神非常紧张在过去4个星期里有多少时间，您觉得心情不好，闷闷不乐？",
                        "option": [
                            {
                                "id": "1",
                                "desc": "常常如此",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "大部分时间",
                                "score": 2
                            },
                            {
                                "id": "3",
                                "desc": "相当多时间",
                                "score": 3
                            },
                            {
                                "id": "4",
                                "desc": "有时",
                                "score": 4
                            },
                            {
                                "id": "5",
                                "desc": "偶尔",
                                "score": 5
                            },
                            {
                                "id": "6",
                                "desc": "从来没有",
                                "score": 6
                            }
                        ]
                    },
                    {
                        "itemId": "g",
                        "desc": "在过去4个星期里有多少时间，您感到筋疲力尽？",
                        "option": [
                            {
                                "id": "1",
                                "desc": "常常如此",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "大部分时间",
                                "score": 1
                            },
                            {
                                "id": "3",
                                "desc": "相当多时间",
                                "score": 1
                            },
                            {
                                "id": "4",
                                "desc": "有时",
                                "score": 1
                            },
                            {
                                "id": "5",
                                "desc": "偶尔",
                                "score": 1
                            },
                            {
                                "id": "6",
                                "desc": "从来没有",
                                "score": 6
                            }
                        ]
                    },
                    {
                        "itemId": "h",
                        "desc": "在过去4个星期里有多少时间，您是个快乐的人？",
                        "option": [
                            {
                                "id": "1",
                                "desc": "常常如此",
                                "score": 6
                            },
                            {
                                "id": "2",
                                "desc": "大部分时间",
                                "score": 5
                            },
                            {
                                "id": "3",
                                "desc": "相当多时间",
                                "score": 4
                            },
                            {
                                "id": "4",
                                "desc": "有时",
                                "score": 3
                            },
                            {
                                "id": "5",
                                "desc": "偶尔",
                                "score": 2
                            },
                            {
                                "id": "6",
                                "desc": "从来没有",
                                "score": 1
                            }
                        ]
                    },
                    {
                        "itemId": "i",
                        "desc": "在过去4个星期里有多少时间，您觉得疲倦？",
                        "option": [
                            {
                                "id": "1",
                                "desc": "常常如此",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "大部分时间",
                                "score": 2
                            },
                            {
                                "id": "3",
                                "desc": "相当多时间",
                                "score": 3
                            },
                            {
                                "id": "4",
                                "desc": "有时",
                                "score": 4
                            },
                            {
                                "id": "5",
                                "desc": "偶尔",
                                "score": 5
                            },
                            {
                                "id": "6",
                                "desc": "从来没有",
                                "score": 6
                            }
                        ]
                    }
                ]
            },
            {
                "groupId": "10",
                "groupName": "在过去4个星期里，有多少时间由于您的身体健康或情绪问题妨碍了您的社交活动（比如探亲、访友等）？",
                "item": [
                    {
                        "itemId": "a",
                        "desc": "",
                        "option": [
                            {
                                "id": "1",
                                "desc": "常常有妨碍",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "大部分时间有妨碍",
                                "score": 2
                            },
                            {
                                "id": "3",
                                "desc": "有时有妨碍",
                                "score": 3
                            },
                            {
                                "id": "4",
                                "desc": "偶尔有妨碍",
                                "score": 4
                            },
                            {
                                "id": "5",
                                "desc": "完全没有妨碍",
                                "score": 5
                            }
                        ]
                    }
                ]
            },
            {
                "groupId": "11",
                "groupName": "如果用下列的句子来形容您，您认为有多正确？",
                "item": [
                    {
                        "itemId": "a",
                        "desc": "您好像比别人更容易生病",
                        "option": [
                            {
                                "id": "1",
                                "desc": "肯定对",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "大致对",
                                "score": 2
                            },
                            {
                                "id": "3",
                                "desc": "不知道",
                                "score": 3
                            },
                            {
                                "id": "4",
                                "desc": "大致不对",
                                "score": 4
                            },
                            {
                                "id": "5",
                                "desc": "肯定不对",
                                "score": 5
                            }
                        ]
                    },
                    {
                        "itemId": "b",
                        "desc": "您好像与所有您认识的人一样健康",
                        "option": [
                            {
                                "id": "1",
                                "desc": "肯定对",
                                "score": 5
                            },
                            {
                                "id": "2",
                                "desc": "大致对",
                                "score": 4
                            },
                            {
                                "id": "3",
                                "desc": "不知道",
                                "score": 3
                            },
                            {
                                "id": "4",
                                "desc": "大致不对",
                                "score": 2
                            },
                            {
                                "id": "5",
                                "desc": "肯定不对",
                                "score": 1
                            }
                        ]
                    },
                    {
                        "itemId": "c",
                        "desc": "您觉得自己的身体状况会变坏",
                        "option": [
                            {
                                "id": "1",
                                "desc": "肯定对",
                                "score": 1
                            },
                            {
                                "id": "2",
                                "desc": "大致对",
                                "score": 2
                            },
                            {
                                "id": "3",
                                "desc": "不知道",
                                "score": 3
                            },
                            {
                                "id": "4",
                                "desc": "大致不对",
                                "score": 4
                            },
                            {
                                "id": "5",
                                "desc": "肯定不对",
                                "score": 5
                            }
                        ]
                    },
                    {
                        "itemId": "d",
                        "desc": "您的健康极好",
                        "option": [
                            {
                                "id": "1",
                                "desc": "肯定对",
                                "score": 5
                            },
                            {
                                "id": "2",
                                "desc": "大致对",
                                "score": 4
                            },
                            {
                                "id": "3",
                                "desc": "不知道",
                                "score": 3
                            },
                            {
                                "id": "4",
                                "desc": "大致不对",
                                "score": 2
                            },
                            {
                                "id": "5",
                                "desc": "肯定不对",
                                "score": 1
                            }
                        ]
                    }
                ]
            }
        ]
    };

    // 栏目的选项的对应关系
    var groupKeys = {
        "pf": ['3-a', '3-b', '3-c', '3-d', '3-e', '3-f', '3-g', '3-h', '3-i', '3-j'], //'3-i',
        "rp": ['4-a', '4-b', '4-c', '4-d'],
        "bp": ['7-a', '8-a'],
        "gh": ['1-a', '11-a', '11-b', '11-c', '11-d'],
        "vt": ['9-a', '9-e', '9-g', '9-i'],
        "sf": ['6-a', '10-a'],
        "re": ['5-a', '5-b', '5-c'],
        "mh": ['9-b', '9-c', '9-d', '9-f', '9-h']
    };

    // 7-a 选择'无'时 8-a 的选项依次是6, 4.75, 3.5, 2.25, 1.0, 否则为5, 4, 3, 2, 1
    var extra = {'8-a': {'0': [6, 4.75, 3.5, 2.25, 1.0], '1': [5, 4, 3, 2, 1], '2-6': [5, 4, 3, 2, 1]}};

    var totalItem = 0; // 选择题总数
    var inputItemScoreList = {}; // 存储所有的选项和分数
    var inputItemValueList = {}; // 存储所有的选项和值
    var resultScore = {}; // 计算后的栏目分数

    // 初始化页面
    var buildPage = function () {
        var data = [];
        data.push('<dl id="sf-36-questions">');

        $.each(pageData.data, function (k, v) {
            var groupId = v.groupId;
            var groupName = v.groupName;
            data.push('<dt>' + groupId + ' ' + groupName + '</dt>');

            var item = v.item;
            totalItem += item.length; // 累加选择题总数

            $.each(item, function (i, j) {
                var itemId = j.itemId;
                var itemDesc = j.desc;
                data.push('<dd style="margin-left: 25px;">' + (itemDesc == '' ? '' : itemId + ' ' + itemDesc) + '</dd><dd><ul>');
                var option = j.option;
                $.each(option, function (m, n) {
                    var optionId = n.id;
                    var optionDesc = n.desc;
                    var optionScore = n.score;
                    data.push('<li style="height:19.5px;padding: 0 0 6.5px 0;">');
                    data.push('<input style="padding: 0;margin: 0;" class="question-radio" type=radio name=' + groupId + '-' + itemId + ' value=' + optionId + ' data-score=' + optionScore + ' />');
                    data.push(optionDesc);
                    data.push('</li>');
                });
                data.push('</ul></dd>');
            });
            data.push('<dd class="dashed-border" style="width: 100%;"></dd>');
        });

        data.push('</dl>');
        $('#table-data').append(data.join(''));
    }

    // 计算分数
    var calcScore = function () {
        // validate there have no selected item?
        var checkedItem = $("#table-data input[type='radio']:checked").length;
        if (checkedItem != totalItem) {
            // console.log('forget item checked?');
            // return;
        }

        var optionItem = $("#table-data input[type='radio']");
        var inputItemScores = {};
        var inputItemValues = {};
        $.each(optionItem, function (i) {
            var n = $(this).attr('name');
            var s = $(this).attr('value');
            inputItemScores[n] = 0;
            inputItemValues[n] = 0;
        });

        var totalScore = 0;
        $.each(inputItemScores, function (v) {
            // var value = $("#table-data input[name='" + v + "']:checked").val();
            var score = $("#table-data input[name='" + v + "']:checked").attr("data-score");
            var value = $("#table-data input[name='" + v + "']:checked").val();
            if (typeof(score) == 'undefined' || score == null || score == "") {
                score = '0';
            }

            if (typeof(value) == 'undefined' || value == null || value == "") {
                value = '0';
            }
            inputItemScores[v] = score;
            inputItemValues[v] = value;
            totalScore += parseFloat(score);
            debugAlert(score);
        });
        inputItemScoreList = inputItemScores;
        inputItemValueList = inputItemValues;

        // 计算每行的分数
        var it = {};
        $.each(groupKeys, function (v) {
            var arr = groupKeys[v];
            var sc = 0;
            $.each(arr, function (k) {
                sc += parseFloat(inputItemScores[arr[k]]);
            });
            it[v] = sc;
        });

        debugAlert("gh:" + it['gh']);

        it['pf'] = ((it['pf'] - 10) * 100 / (30 - 10)).toFixed(2);
        it['rp'] = ((it['rp'] - 4) * 100 / (8 - 4)).toFixed(2);
        it['bp'] = ((it['bp'] - 2) * 100 / (12 - 2)).toFixed(2);
        it['gh'] = ((it['gh'] - 5) * 100 / (25 - 5)).toFixed(2);
        it['vt'] = ((it['vt'] - 4) * 100 / (24 - 4)).toFixed(2);
        it['sf'] = ((it['sf'] - 2) * 100 / (10 - 2)).toFixed(2);
        it['re'] = ((it['re'] - 3) * 100 / (6 - 3)).toFixed(2);
        it['mh'] = ((it['mh'] - 5) * 100 / (30 - 5)).toFixed(2);

        // 展示每个栏目的得分
        resultScore = it;
        $.each(it, function (v) {
            // console.log('item=>' + v + ' score=>' + it[v]); // 每个栏目的分数
            $("." + v).text(it[v]);
        });
    }

    var listenRadioChange = function () {
        $('#table-data input[type="radio"]').click(function () {
            debugAlert('radio changed!');
            // 判断7-a与8-a的状态
            checkSpecifyRadio(this);

            calcScore();
        });
    }
    
    // 初始化页面
    buildPage();
    
    // 监听按钮选择变更
    listenRadioChange();

    /**
    * 判断指定的选项变更关系 如 7-a的变动影响8-a的选项值
    * 那规则就是：7没回答，8的选项得分分别是6/4.75/3.5/2.25/1
    * 7选择1时，8的得分为5/4/3/2/1
    * 7选择2-6时，8的得分依次是 5、4、3、2、1
    */ 
    var checkSpecifyRadio = function (i) {
        if(i == null) {
            if(typeof($("#table-data input[name='7-a']:checked")) != "undefined" && $("#table-data input[name='7-a']:checked") != null) {
                var val = $("#table-data input[name='7-a']:checked").val();
                init8A(val);
            }
        }
        else if ('7-a' == $(i).attr('name')) {
            var val = $(i).val();
            init8A(val);
        }

    }

    function init8A(val) {
        if (val == 1) {
            $("#table-data input[name='8-a']").each(function (idx) {
                $(this).attr('data-score', extra['8-a']['1'][idx]);
            });
        } else if(val >= 2 && val <= 6) {
            $("#table-data input[name='8-a']").each(function (idx) {
                $(this).attr('data-score', extra['8-a']['2-6'][idx]);
            });
        } else {
            $("#table-data input[name='8-a']").each(function (idx) {
                $(this).attr('data-score', extra['8-a']['0'][idx]);
            });
        }
    }

    function setEditable(edit) {
        if (edit) {
            editPage.removeClass('hide');
            viewPage.addClass('hide');
        } else {
            viewPage.removeClass('hide');
            editPage.addClass('hide');
            $(".question-radio").attr('disabled', 'disabled');

            // 设置栏目得分为不可编辑状态
            $("#table_total input").attr('disabled', 'disabled').css("background-color", "#FFF");
            $("#gauge_form input").attr('disabled', 'disabled');
        }
    }

    function setGaugeResult(result) {
        $.each(result.questions, function (idx, val) {
            if(val != null && val != "") {
                $("#sf-36-questions input[type='radio'][name='" + idx + "'][value='" + val + "']").prop("checked", "checked");
            }
        });

        // 设置陪同者
        $("#span_companion_edit").val(result.companion);

        checkSpecifyRadio();
        calcScore();
    }

    function getGaugeResult() {
        // 检查是否所有的选项都被选择
        if (!checkItemComplete()) {
            return null;
        }

        // 陪同者名称
        var companion = $("#span_companion_edit").val().trim();
        var result = {'questions': inputItemValueList, 'resultScore': resultScore, 'companion': companion};
        debugAlert(result);
        return result;
    }

    var checkItemComplete = function () {
        var checkedItem = $("#table-data input[type='radio']:checked").length;
        var n = totalItem - checkedItem;
        if (n != 0) {
            //差一个没有选择
            if(n == 1) {
                //是第7个没有选择
                if(!$("#table-data input[name='7-a']").prop("checked")) {
                    return true;
                } else {
                    utils.msgError("请完成所有问题");
                    return false;
                }
            } else {
                utils.msgError("请完成所有问题");
                return false;
            }

        }
        return true;
    }

    function getCount() {
        $(".pf").text(null);
        $(".rp").text(null);
        $(".bp").text(null);
        $(".gh").text(null);
        $(".vt").text(null);
        $(".sf").text(null);
        $(".re").text(null);
        $(".mh").text(null);
    }

</script>
</html>